/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package views.JPanel;


import controllers.entity.CanBo;
import controllers.entity.ChamThi;
import controllers.entity.Children;
import controllers.entity.DeTai;
import controllers.entity.GiangDay;
import controllers.entity.Paper;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterException;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import models.CanBoDAO;
import models.ChamThiDAO;
import models.ChildrenDAO;
import models.Constant;
import models.DBConnect;
import models.DeTaiDAO;
import models.GiangDayDAO;
import models.PaperDAO;

/**
 *
 * @author HoaDuyen
 */
public class ThongKe extends javax.swing.JPanel {

    /**
     * Creates new form ThongKe1
     */
    private JFrame window;

    final DefaultComboBoxModel model = new DefaultComboBoxModel();
    private int tk=0;
    DefaultTableModel tblModel = new DefaultTableModel();
    private int ii=0;
    public ThongKe(JFrame win) {
        initComponents();
        this.window=win;
        //comboBox1.setEditable(false);
       
    }
    public void Show()
    {
        this.setBounds(160, 0, 800, 600);
        window.add(this);
        this.setVisible(true);
        ComboBox1.setSelectedIndex(0);
        loadTableDataThongKeNhanVien();
        tblModel = null;
        tfheso.setText("1.0");
        tftuoi.setText("15");
        tfluong.setText("2000000");
    }
    private void loadTableDataThongKeNhanVien() {
        DBConnect.Connect();
        List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("MaCB");
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
                tblModel.addColumn("Đảng viên");
		 for (CanBo category : canboLis) {
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getMaCanBo()));
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
                    row.addElement(String.valueOf(category.getDangVien()));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);
               
    }
    private void loadTableDataThongKeDangVien() {
        DBConnect.Connect();
        List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
		 for (CanBo category : canboLis) 
                 if (category.getDangVien()){
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);
               
    }
    private void loadTableDataThongKeDoanVien() {
        DBConnect.Connect();
        List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
		 for (CanBo category : canboLis) 
                 if (category.getDoanVien()){
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);
               
    }
    private void loadTableDataThongKeCongDoanVien() {
        DBConnect.Connect();
        List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
		 for (CanBo category : canboLis) 
                 if (category.getCongDoanVien()){
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);
               
    }
     private void loadTableDataPhiCongDoan() {
        DBConnect.Connect();
        if (tfluong.getText().equals("")){
            JOptionPane.showMessageDialog(this,"Nhập giá trị vào lương tối thiểu !");
            tfluong.requestFocus();
            return;
        }
        float luongtoithieu;
        try {
            luongtoithieu = Float.parseFloat(tfluong.getText());
        } catch(Exception e){
            JOptionPane.showMessageDialog(this,"Nhập số thực !");
            tfluong.selectAll();
            tfluong.requestFocus();
            return;
        }
        List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
                tblModel.addColumn("Phí Công đoàn");
		 for (CanBo category : canboLis) {
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
                    float phicongdoan=(category.getHeSoLuong()+category.getPhuCapChucVu())*luongtoithieu/100;
                    row.addElement(String.valueOf(phicongdoan));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);
               
    }
      private void loadTableDataDangPhi() {
        DBConnect.Connect();
        if (tfluong.getText().equals("")){
            JOptionPane.showMessageDialog(this,"Nhập giá trị vào lương tối thiểu !");
            tfluong.requestFocus();
            return;
        }
        float luongtoithieu;
        try {
            luongtoithieu = Float.parseFloat(tfluong.getText());
        } catch(Exception e){
            JOptionPane.showMessageDialog(this,"Nhập số thực !");
            tfluong.selectAll();
            tfluong.requestFocus();
            return;
        }
        List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
                tblModel.addColumn("Đảng phí");
		 for (CanBo category : canboLis) {
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
                    float phicongdoan=(category.getHeSoLuong()+category.getPhuCapChucVu()+category.getPhuCapGiangDay())*luongtoithieu/100;
                    row.addElement(String.valueOf(phicongdoan));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);    
    }
      private void loadTableTienThi(){
           DBConnect.Connect();
           if (tfheso.getText().equals("")){
            JOptionPane.showMessageDialog(this,"Nhập giá trị hệ số !");
            tfheso.requestFocus();
            return;
            }
            float heso;
            try {
                heso = Float.parseFloat(tfheso.getText());
            } catch(Exception e){
                JOptionPane.showMessageDialog(this,"Nhập số thực !");
                tfheso.selectAll();
                tfheso.requestFocus();
                return;
            }
           List<CanBo> canboLis = CanBoDAO.getAllCanBo();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Số điện thoại");
                tblModel.addColumn("Chức danh");
                tblModel.addColumn("Chức vụ");
                tblModel.addColumn("Tiền Thi");
		 for (CanBo category : canboLis) {
                    List<ChamThi>chamthiLis=ChamThiDAO.getAllChamThiByMaCanBo(category.getMaCanBo());
                    int baithi=0;
                    for (ChamThi chamthi:chamthiLis){
                        baithi+=chamthi.getSoBaiThi();
                    }
                    Vector<String> row = new Vector<>();
                    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getSoDienThoai()));
                    row.addElement(String.valueOf(category.getChucDanh()));
                    row.addElement(String.valueOf(category.getChucVu()));
                    float phicongdoan=baithi*heso;
                    row.addElement(String.valueOf(phicongdoan));
                    tblModel.addRow(row);
		}
		tblData.setModel(tblModel); 
      }
      private void loadTableChildren(){
          DBConnect.Connect();
           if (tftuoi.getText().equals("")){
            JOptionPane.showMessageDialog(this,"Nhập giá trị tuổi !");
            tftuoi.requestFocus();
            return;
            }
            int tuoi;
            try {
                tuoi = Integer.parseInt(tftuoi.getText());
            } catch(Exception e){
                JOptionPane.showMessageDialog(this,"Nhập giá trị nguyên !");
                tftuoi.selectAll();
                tftuoi.requestFocus();
                return;
            }
          List<Children> canboLis = ChildrenDAO.getAllChildren();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Ngày Sinh");
                tblModel.addColumn("Giới Tính");
                tblModel.addColumn("Thành Tích");
		 for (Children category : canboLis) {
                     java.util.Date today = new java.util.Date();
                     if ((today.getTime() - category.getNgaySinh().getTime())/31536000 <= tuoi*1000){
                          Vector<String> row = new Vector<>();
                          row.addElement(String.valueOf(category.getHoTen()));
                          row.addElement(String.valueOf(category.getNgaySinh()));
                          row.addElement(String.valueOf(category.getGoiTinh()));
                          row.addElement(String.valueOf(category.getThanhTich()));
                        tblModel.addRow(row);
                     }
		}
		tblData.setModel(tblModel);  
      }
      private void loadTableGoodChildren(){
          DBConnect.Connect();
          List<Children> canboLis = ChildrenDAO.getAllChildrenHSG();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Họ tên");
                tblModel.addColumn("Ngày Sinh");
                tblModel.addColumn("Giới Tính");
                tblModel.addColumn("Thành Tích");
		 for (Children category : canboLis) {
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getHoTen()));
                    row.addElement(String.valueOf(category.getNgaySinh()));
                    row.addElement(String.valueOf(category.getGoiTinh()));
                    row.addElement(String.valueOf(category.getThanhTich()));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);  
      }
      private void loadTablePaper(){
          DBConnect.Connect();
          List<Paper> paperLis = PaperDAO.getAllPaper();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Tên tạp chí");
                tblModel.addColumn("Số");
                tblModel.addColumn("Thời gian");
                tblModel.addColumn("Hệ số IF");
                tblModel.addColumn("Chỉ số ISSN");
		 for (Paper category : paperLis) {
		    Vector<String> row = new Vector<>();
		    row.addElement(String.valueOf(category.getTenTapChi()));
                    row.addElement(String.valueOf(category.getSo()));
                    row.addElement(String.valueOf(category.getThoiGian()));
                    row.addElement(String.valueOf(category.getIF()));
                    row.addElement(String.valueOf(category.getISSN()));
		    tblModel.addRow(row);
		}
		tblData.setModel(tblModel);  
      }
      private void loadTableNCKH(){
          DBConnect.Connect();
          List<CanBo> canboLis = CanBoDAO.getAllCanBo();
                tblModel = new DefaultTableModel();
                tblModel.addColumn("Tên đề tài");
                tblModel.addColumn("Cấp");
                tblModel.addColumn("Kinh Phí");
                tblModel.addColumn("Chủ trì để tài");
                tblModel.addColumn("Tình trạng");
		 for (CanBo canbo : canboLis) {
                    List<DeTai> detaiLis = DeTaiDAO.getAllDeTaiByMaCanBo(canbo.getMaCanBo());
                    for (DeTai category:detaiLis){
                        Vector<String> row = new Vector<>();
                        row.addElement(String.valueOf(category.getTenDeTai()));
                        row.addElement(String.valueOf(category.getCap()));
                        row.addElement(String.valueOf(category.getKinhPhi()));
                        row.addElement(String.valueOf(category.getChuDeTai()));
                        row.addElement(String.valueOf(category.getTinhTrang()));
                        tblModel.addRow(row);
                    }
		}
		tblData.setModel(tblModel);
          
      }
      private void loadTableFinishNCKH(){
          DBConnect.Connect();
          List<CanBo> canboLis = CanBoDAO.getAllCanBo();
                tblModel = new DefaultTableModel();
                tblModel.addColumn("Tên đề tài");
                tblModel.addColumn("Cấp");
                tblModel.addColumn("Kinh Phí");
                tblModel.addColumn("Chủ trì để tài");
                tblModel.addColumn("Kết Quả");
		 for (CanBo canbo : canboLis) {
                    List<DeTai> detaiLis = DeTaiDAO.getAllDeTaiByMaCanBo(canbo.getMaCanBo());
                    for (DeTai category:detaiLis){
                        if (category.getTinhTrang().equals("Hoàn thành")){
                            Vector<String> row = new Vector<>();
                            row.addElement(String.valueOf(category.getTenDeTai()));
                            row.addElement(String.valueOf(category.getCap()));
                            row.addElement(String.valueOf(category.getKinhPhi()));
                            row.addElement(String.valueOf(category.getChuDeTai()));
                            row.addElement(String.valueOf(category.getKetQua()));
                            tblModel.addRow(row);
                        }
                    }
		}
		tblData.setModel(tblModel);
      }
      private void loadTableMonHoc(){
           DBConnect.Connect();
           List<GiangDay> giangdayLis = GiangDayDAO.getAllGiangDay();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Mã môn học");
                tblModel.addColumn("Tên môn học");
                tblModel.addColumn("Số tín chỉ");
		for (GiangDay category : giangdayLis) {
                    Vector<String> row = new Vector<>();
                    row.addElement(String.valueOf(category.getMaMonHoc()));
                    row.addElement(String.valueOf(category.getTenMonHoc()));
                    row.addElement(String.valueOf(category.getSoTinChi()));
                    tblModel.addRow(row);
		}
		tblData.setModel(tblModel); 
      }
      private void loadTableMonHocThi(){
          DBConnect.Connect();
           List<ChamThi> chamthiLis = ChamThiDAO.getAllChamThi();
		tblModel = new DefaultTableModel();
		tblModel.addColumn("Mã môn học");
                tblModel.addColumn("Mã lớp học");
                tblModel.addColumn("Số bài thi");
		for (ChamThi category : chamthiLis) {
                    if (category.getNgayNop().getTime()<System.currentTimeMillis()){
                        Vector<String> row = new Vector<>();
                        row.addElement(String.valueOf(category.getMaMonHoc()));
                        row.addElement(String.valueOf(category.getMaLopHoc()));
                        row.addElement(String.valueOf(category.getSoBaiThi()));
                    tblModel.addRow(row);
                    }
		}
		tblData.setModel(tblModel); 
      }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        in = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblData = new javax.swing.JTable();
        ComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tfluong = new javax.swing.JTextField();
        tftuoi = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tfheso = new javax.swing.JTextField();
        thongke = new javax.swing.JButton();

        setBackground(new java.awt.Color(102, 204, 255));

        in.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/btn_save.png"))); // NOI18N
        in.setText("In");
        in.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inActionPerformed(evt);
            }
        });

        jLabel1.setText("Thống Kê");

        tblData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblData.setEnabled(false);
        jScrollPane1.setViewportView(tblData);

        ComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Danh sách cán bộ", "Danh sách Đảng viên", "Danh sách Công Đoàn viên", "Danh sách Đoàn viên", "Bảng thu phí Công đoàn", "Bảng thu Đảng phí", "Bảng tính tiền chấm thi", "Danh sách các cháu theo độ tuổi", "Danh sách các cháu là học sinh giỏi", "Danh sách bài báo tạp chí", "Danh sách đề tài NCKH", "Danh sách đề tài NCKH đã hoàn thành", "Danh sách môn học", "Danh sách môn học đã nộp bài thi" }));
        ComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComboBox1ActionPerformed(evt);
            }
        });

        jLabel2.setText("Lương tối thiểu");

        jLabel3.setText("Tuổi");

        tfluong.setText("1000000");
        tfluong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfluongActionPerformed(evt);
            }
        });

        tftuoi.setText("15");

        jLabel4.setText("Hệ số ");

        tfheso.setText("10");
        tfheso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfhesoActionPerformed(evt);
            }
        });

        thongke.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/table.png"))); // NOI18N
        thongke.setText("Thống Kê");
        thongke.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                thongkeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(223, 223, 223)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(42, 42, 42)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tftuoi, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(tfluong, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(tfheso, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(ComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(thongke)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(357, 357, 357)
                        .addComponent(in)))
                .addContainerGap(238, Short.MAX_VALUE))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tfluong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(tfheso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(tftuoi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(4, 4, 4)
                .addComponent(thongke)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(79, 79, 79)
                .addComponent(in)
                .addContainerGap(38, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void inActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inActionPerformed
        ii=0; 
        ActionListener printAction = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    System.out.println("hoa");
                    ii++;
                    if (ii==1){
                        tblData.print(JTable.PrintMode.FIT_WIDTH);
                    }
                } catch (PrinterException pe) {
                    System.err.println("Error printing: " + pe.getMessage());
                }
            }
            };
            in.addActionListener(printAction);
    }//GEN-LAST:event_inActionPerformed

    private void ComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComboBox1ActionPerformed
        if (ComboBox1.getSelectedItem().equals("Danh sách cán bộ")){
            tk=1;
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách Đảng viên")){
            tk=2;
            
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách Công Đoàn viên")){
            tk=3;
           
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách Đoàn viên")){
            tk=4;
           
        }
        if (ComboBox1.getSelectedItem().equals("Bảng thu phí Công đoàn")){
            tk=5;
            
        }
        if (ComboBox1.getSelectedItem().equals("Bảng thu Đảng phí")){
            tk=6;
            
        }
        if (ComboBox1.getSelectedItem().equals("Bảng tính tiền chấm thi")){
            tk=7;
            
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách các cháu theo độ tuổi")){
            tk=8;
            
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách các cháu là học sinh giỏi")){
            tk=9;
           
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách bài báo tạp chí")){
            tk=10;
           
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách đề tài NCKH")){
            tk=11;
            
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách đề tài NCKH đã hoàn thành")){
            tk=12;
            
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách môn học")){
            tk=13;
           
        }
        if (ComboBox1.getSelectedItem().equals("Danh sách môn học đã nộp bài thi")){
            tk=14;
           
        }             
    }//GEN-LAST:event_ComboBox1ActionPerformed

    private void tfluongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfluongActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfluongActionPerformed

    private void tfhesoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfhesoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfhesoActionPerformed

    private void thongkeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_thongkeActionPerformed
       switch(tk){
           case 1:
               loadTableDataThongKeNhanVien();
               break;
           case 2:
               loadTableDataThongKeDangVien();
               break;
           case 3:
                loadTableDataThongKeCongDoanVien();
               break;
           case 4:
                loadTableDataThongKeDoanVien();
               break;
           case 5:
               loadTableDataPhiCongDoan();
               break;
           case 6:
               loadTableDataDangPhi();
               break;
           case 7:
               loadTableTienThi();
               break;
           case 8:
               loadTableChildren();
               break;
           case 9:
                loadTableGoodChildren();
               break;
           case 10:
                loadTablePaper();
               break;
           case 11:
               loadTableNCKH();
               break;
           case 12:
               loadTableFinishNCKH();
               break;
           case 13:
                loadTableMonHoc();
               break;
           case 14:
                loadTableMonHocThi();
               break;
               
            
       }
    }//GEN-LAST:event_thongkeActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox ComboBox1;
    private javax.swing.JButton in;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblData;
    private javax.swing.JTextField tfheso;
    private javax.swing.JTextField tfluong;
    private javax.swing.JTextField tftuoi;
    private javax.swing.JButton thongke;
    // End of variables declaration//GEN-END:variables
}
